﻿using HomagChina.CCHCS.DataTypeModel;
using HomagChina.CCHCS.ViewModels;
using HomagChina.CCHCS.Views;
using HomagGroup.Base.UI;
using HomagGroup.Base.UI.Themes.Resources;
using System.Collections.ObjectModel;
using static HomagChina.CCHCS.ProcessResourceInternal;
using static HomagChina.CCHCS.Utility;

namespace HomagChina.CCHCS.Router
{
    public class BoardlibraryRoute
    {
        public RouterItemDataModel BoardlibraryRouteModel { get; set; }

        public BoardlibraryRoute()
        {
            BoardLibraryViewModel model = new BoardLibraryViewModel();
            BoardLibrary userControl = GetUserControlInstance("BoardLibrary") as BoardLibrary;
            model.RequestScrollPositionSave += userControl.ViewModel_RequestScrollPositionSave;
            model.RequestScrollPositionRestore += userControl.ViewModel_RequestScrollPositionRestore;
            BoardlibraryRouteModel = new RouterItemDataModel()
            {
                ID = "BoardLibrary",
                viewLabel = GetLocalText("Boardibrary"),
                viewName = "BoardLibrary",
                viewModelName = "BoardlibraryViewModel",
                ViewModel = model,
                keepalive = false,
                userControl = GetUserControlInstance("BoardLibrary"),
                Image = null,
                functionKeyBarItems = new ObservableCollection<FunctionKeyBarItemDataModel>{
                    //new FunctionKeyBarItemDataModel() {
                    //    Header =  GetLocalText("Exit"),
                    //    Position = 12,
                    //    Icon = GetIconBrush(Icon.Close, ImageDecoration.Circle),
                    //    Command = new RelayCommand(() => { Application.Current.Shutdown(); })
                    //},

                    new FunctionKeyBarItemDataModel() {
                        Header = GetLocalText("Add"),
                        Position = 9,
                        Icon = GetIconBrush(Icon.Database, ImageDecoration.Box),
                        Command = new RelayCommand(() => {  model.BoardAdd(); })
                    },

                    new FunctionKeyBarItemDataModel() {
                        Header =  GetLocalText("Import"),
                        Position = 8,
                        Icon = GetIconBrush(Icon.Database, ImageDecoration.Box),
                        Command = new RelayCommand(() => { model.HandleOpenMprFile(); })
                    },
                      new FunctionKeyBarItemDataModel() {
                        Header = GetLocalText("Delete"),
                        Position = 6,
                        Icon = GetIconBrush(Icon.Delete, ImageDecoration.Circle),
                        Command = new RelayCommand(() => { model.Delete(); })
                    },
                }
            };
            BoardlibraryRouteModel.userControl.DataContext = model;
        }
    }
}